﻿imports System.Text 
Public Class clsvi_GetTrustee
	 inherits ADODBU.Recordset 
	 
	 private mFieldList as New ArrayList 
	 private mStrFieldList as string 
	 private mStrSql as string 
	public Sub New()
	mFieldList.Add("vi_GetTrustee.Mod_Group")
	mFieldList.Add("vi_GetTrustee.Mod_ID")
	mFieldList.Add("vi_GetTrustee.Parent_ID")
	mFieldList.Add("vi_GetTrustee.Mod_Name")
	mFieldList.Add("vi_GetTrustee.Mod_Desc")
	mFieldList.Add("vi_GetTrustee.Mod_URL")
	mFieldList.Add("vi_GetTrustee.User_names")
	mFieldList.Add("vi_GetTrustee.Kd_User")
	mFieldList.Add("vi_GetTrustee.Mod_Img")
	mFieldList.Add("vi_GetTrustee.APP_ID")
	mFieldList.Add("vi_GetTrustee.Mod_Key")
	mFieldList.Add("vi_GetTrustee.Mod_ImgURL")
	mFieldList.Add("vi_GetTrustee.Parent_Group")
	mFieldList.Add("vi_GetTrustee.Mod_Type")
        mFieldList.Add("vi_GetTrustee.Mod_Row")
        mFieldList.Add("vi_GetTrustee.Aktif")
        mStrSql = "Select Mod_Group,Mod_ID,Parent_ID,Mod_Name,Mod_Desc,Mod_URL,User_names,Kd_User,Mod_Img,APP_ID,Mod_Key,Mod_ImgURL,Parent_Group,Mod_Type,Mod_Row,Aktif from vi_GetTrustee  "
	End Sub
	 
	Public overloads Sub Open( cCriteria as string )
		dim cSql as string 
		 cSql=mStrSql & cCriteria
		mybase.AddPk("Mod_Group")
		mybase.AddPk("Mod_ID")
		mybase.AddPk("Kd_User")
		mybase.IscanUpdate=true 
		try 
		mybase.Open(cSql,"vi_GetTrustee",me.dbConn)
		Catch e as Exception 
		me.ErrMessage =e.message
		end try
	End sub
 
 
	Public Function GetRowList(dbConn as adodbu.dbconn,cCriteria as string) as ADODBU.RowClassList(of clsvi_GetTrusteeRow) 
		Dim cmd As System.Data.IDbCommand = dbConn.DBAFactory.GetCommand
		cmd.CommandText = Me.mstrSql & cCriteria 
		cmd.CommandType = CommandType.Text
		cmd.Connection = dbConn.Connection
		Return GetDataFromReader(cmd.ExecuteReader)
	End Function 
 
	Public Function GetRowList() as ADODBU.RowClassList(of clsvi_GetTrusteeRow) 
		Return Me.GetDataFromReader(Me.DataTable.CreateDataReader) 
	End Function 
	private Function GetDataFromReader(ByVal rdr As IDataReader) As ADODBU.RowClassList(Of clsvi_GetTrusteeRow)
		dim colData as new ADODBU.RowClassList(of clsvi_GetTrusteeRow)
		dim xData as clsvi_GetTrusteeRow 
        'Dim buffer() As Byte
        'Dim len As Long 
		Dim mStr As New System.IO.MemoryStream 
		 
		Do While rdr.Read
		 xData = New clsvi_GetTrusteeRow()
			If Not rdr.IsDBNull(0) Then 
			 xData.Mod_Group= rdr.GetString(0)
			End If 
			If Not rdr.IsDBNull(1) Then 
			 xData.Mod_ID= rdr.GetString(1)
			End If 
			If Not rdr.IsDBNull(2) Then 
			 xData.Parent_ID= rdr.GetString(2)
			End If 
			If Not rdr.IsDBNull(3) Then 
			 xData.Mod_Name= rdr.GetString(3)
			End If 
			If Not rdr.IsDBNull(4) Then 
			 xData.Mod_Desc= rdr.GetString(4)
			End If 
			If Not rdr.IsDBNull(5) Then 
			 xData.Mod_URL= rdr.GetString(5)
			End If 
			If Not rdr.IsDBNull(6) Then 
			 xData.User_names= rdr.GetString(6)
			End If 
			If Not rdr.IsDBNull(7) Then 
			 xData.Kd_User= rdr.GetString(7)
			End If 
			If Not rdr.IsDBNull(8) Then 
			 xData.Mod_Img= rdr.GetString(8)
			End If 
			If Not rdr.IsDBNull(9) Then 
			 xData.APP_ID= rdr.GetString(9)
			End If 
			If Not rdr.IsDBNull(10) Then 
			 xData.Mod_Key= rdr.GetString(10)
			End If 
			If Not rdr.IsDBNull(11) Then 
			 xData.Mod_ImgURL= rdr.GetString(11)
			End If 
			If Not rdr.IsDBNull(12) Then 
			 xData.Parent_Group= rdr.GetString(12)
			End If 
			If Not rdr.IsDBNull(13) Then 
			 xData.Mod_Type= rdr.GetInt32(13)
			End If 
			If Not rdr.IsDBNull(14) Then 
			 xData.Mod_Row= rdr.GetInt32(14)
            End If
			colData.Add(xData)
		Loop
		rdr.close()
		rdr.Dispose()
		Return colData 
	End Function 
 
	Public Function GetClassRow() as clsvi_GetTrusteeRow 
		dim crData as new clsvi_GetTrusteeRow 
		crData = GetClassRow(me.getcurrentdataRow)
		Return crData 
	End Function 
 
 
	Public Function GetClassRow(recdata as ADODBU.Recordset) as clsvi_GetTrusteeRow 
		dim crData as clsvi_GetTrusteeRow 
		crData = new clsvi_GetTrusteeRow(recdata.getcurrentdataRow) 
		Return crData 
	End Function 
 
 
	Public Function GetClassRow(recdata as DataRow) as clsvi_GetTrusteeRow 
		return new clsvi_GetTrusteeRow(recdata) 
	End Function 
 
 
	Public Function SaveClassRow(crData as clsvi_GetTrusteeRow ,lAddnew as boolean,Optional lTransaction as boolean=false ) as boolean
		dim lSavedata as boolean
		if lAddnew then 
			Mybase.AddNew 
		End if 
		crData.DataSource = me
		crData.SaveToDataSource
		lSaveData=True
		Try 
			Mybase.Update(lTransaction) 
			if Mybase.errMessage.Length<>0 then 
				lSaveData=false
			end if 
		Catch e As Exception
			lSaveData=false
		End Try 
		Return lSavedata 
	End Function 
 

End Class
